// pages/backlog/backlog.js
let app = getApp()
let request = require('../../utils/request')
const util = require("../../utils/util.js")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageAllHeight: app.globalData.pageAllHeight,
    navs:true,
    date:util.formatDates(new Date())[0],  //获取当前月份
    tabIndex: 0,
    tabs: [{
      id: 1,
      name: '全部',
      select: true
    },
    {
      id: 2,
      name: '停车费',
      select: false
    },
    {
      id: 3,
      name:'预约费',
      select: false
    },
    {
      id: 4,
      name:'停车卡费',
      select: false
    }],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  // 日期改变出发事件
  bindDateChange(e) {
    let str = e.detail.value
    // 去除0 参数 
    let strArray = str.split("-");
    strArray = strArray.map(function(val) {
      if (val[0] == "0") {
        return (val = val.slice(1));
      } else {
        return val;
      }
    });
    console.log(strArray);
    this.setData({ date:strArray[1] })
  },

  // tab切换
  selectTab(e) {
    let index = e.target.dataset.index;
    let that = this;
    let tabs = that.data.tabs;
    for (let i = 0; i < tabs.length; i++) {
      if (i == index) {
        tabs[i].select = true
      } else {
        tabs[i].select = false;
      }
    }
    that.setData({
      tabIndex: index,
      tabs: tabs
    })
  },
  bindchange(e) {
    let index = e.detail.current
    let tabs = this.data.tabs;
    for (let i = 0; i < tabs.length; i++) {
      if (i == index) {
        tabs[i].select = true
      } else {
        tabs[i].select = false;
      }
    }
    this.setData({
      tabIndex: index,
      tabs: tabs,
      orderStatus: tabs[index].id,
      StopInfoCurrentPage: 1,
      isCanNext: true
    })
  },
  
  // 跳转账单详情
  toBillDetail() {
    wx.navigateTo({
      url: '/pages/billDetail/billDetail',
    })
  },

})